<?php $jenis = $this->referensi->get_list_referensi('sekolah_jenis','id','sekolah_jenis') ?>
<?php $jenjang = $this->referensi->get_list_referensi('jenjang_pendidikan','id','jenjang_pendidikan') ?>
<?php $kecamatan = $this->referensi->get_list_referensi('kecamatan','id','kecamatan') ?>
<?php $jk = $this->referensi->get_list_referensi('jenis_kelamin','id','jenis_kelamin') ?>
<h2>Rekap Jumlah Guru <?php echo $jenis[$jenis_id] ?> Menurut Ijazah Tertinggi</h2>
<table class="table">
	<thead>
		<tr>
			<th rowspan=3 width=10px>No.</th>
			<th rowspan=3>Kecamatan</th>
			<th colspan=<?php echo (count($jk)+1) * count($jenjang) ?>>Jumlah Guru Menurut Menurut Ijazah Tertinggi</th>
		</tr>		
		<tr>
			<?php foreach($jenjang as $detail):?>
				<th colspan=<?php echo count($jk)?>><?php echo $detail ?></th>
				<th rowspan=2>L+P</th>
			<?php endforeach ?>
		</tr>
		<tr>
			<?php foreach($jenjang as $detail):?>
				<?php foreach($jk as $detail):?>
					<th><?php echo substr($detail,0,1) ?></th>
				<?php endforeach ?>
			<?php endforeach ?>
		</tr>
	</thead>
	<tbody>
		<?php $no=1 ?>
		<?php $total  = array() ?>
		<?php foreach($kecamatan as $idkec=>$kec): ?>
		<tr>			
			<td class="center"><?php echo $no++ ?></td>
			<td><?php echo $kec ?></td>
			<?php foreach($jenjang as $ids=>$sta):?>	
				<?php $jml=0 ?>			
				<?php foreach($jk as $idd=>$std): ?>
					<?php $val = isset($data[$idkec][$ids][$idd])?$data[$idkec][$ids][$idd]:0 ?>
					<?php isset($total[$ids][$idd])? $total[$ids][$idd] +=$val : $total[$ids][$idd]=$val ?>
					<td  class="center"><?php echo $val ?></td>
					<?php $jml+=$val ?>
				<?php endforeach ?>
				<td  class="center"><?php echo $jml ?></td>
			<?php endforeach ?>			
		</tr>
		<?php endforeach ?>
		<tr>
			<td colspan=2>Total</td>
			<?php $jml = 0 ?>
			<?php foreach($jenjang as $ids=>$sta):?>				
				<?php $jml=0 ?>			
				<?php foreach($jk as $idd=>$std) : ?>
					<?php $val = $total[$ids][$idd] ?>
					<td  class="center"><?php echo $val ?></td>
					<?php $jml+=$val ?>
				<?php endforeach ?>
				<td  class="center"><?php echo $jml ?></td>
			<?php endforeach ?>
		</tr>
	</tbody>
</table>